require('dotenv').config();
const { Client } = require('pg');

async function queryUsers() {
  const client = new Client({
    host: process.env.DB_HOST || '43.162.111.101',
    port: parseInt(process.env.DB_PORT || '5432', 10),
    user: process.env.DB_USERNAME || 'myuser',
    password: process.env.DB_PASSWORD || '123456',
    database: process.env.DB_NAME || 'dating_app',
  });

  try {
    await client.connect();
    console.log('数据库连接成功');
    
    const res = await client.query('SELECT id, phone, name FROM users WHERE phone = $1', ['123']);
    console.log('手机号为123的用户:');
    console.log(res.rows);
    
    await client.end();
  } catch (err) {
    console.error('查询出错:', err);
  }
}

queryUsers();